Skip to content

Conversation

@haakon-e
Copy link
Member

@haakon-e haakon-e commented Oct 9, 2025

This pull request refactors and streamlines the hyperdiffusion logic in src/prognostic_equations/hyperdiffusion.jl, focusing on code clarity, maintainability, and consistency.

Key improvements and changes:

  • extract components from parent structs (e.g. moisture_model from atmos, or ᶜu from p.precomputed) to simplify and shorten their inline usage
  • combined multi-line assignments and expressions, making code more concise.
  • give new names to 4th order derivatives to clarify their usage.
    For example, instead of the (somewhat confusing) expression
@. ᶜ∇²u =
        divergence_damping_factor * C123(wgradₕ(divₕ(ᶜ∇²u))) -
        C123(wcurlₕ(C123(curlₕ(ᶜ∇²u))))
@. Yₜ.c.uₕ -= ν₄_vorticity * C12(ᶜ∇²u)

I propose assigning a new name to the resulting calculation. Importantly, this does not affect the underlying memory of the data

ᶜ∇⁴u = @. ᶜ∇²u =
        divergence_damping_factor * C123(wgradₕ(divₕ(ᶜ∇²u))) -
        C123(wcurlₕ(C123(curlₕ(ᶜ∇²u))))
@. Yₜ.c.uₕ -= ν₄_vorticity * C12(ᶜ∇⁴u)

These changes collectively improve the maintainability and readability of the hyperdiffusion implementation, while ensuring consistent and correct use of model parameters throughout the codebase.

@haakon-e
Copy link
Member Author

haakon-e commented Oct 9, 2025

This change is part of the following stack:

Change managed by git-spice.

@haakon-e haakon-e force-pushed the rft-clean-up-hyperdiffusion branch from ffc9b1d to 34d9fa8 Compare October 14, 2025 16:59
@haakon-e haakon-e force-pushed the rft-clean-up-hyperdiffusion branch from 34d9fa8 to f37cac9 Compare October 24, 2025 17:25
@haakon-e haakon-e force-pushed the rft-clean-up-hyperdiffusion branch from f37cac9 to a3d73be Compare October 24, 2025 21:50
@haakon-e haakon-e enabled auto-merge October 24, 2025 21:57
@haakon-e haakon-e added this pull request to the merge queue Oct 24, 2025
Merged via the queue into main with commit 560c329 Oct 24, 2025
19 checks passed
@haakon-e haakon-e deleted the rft-clean-up-hyperdiffusion branch October 24, 2025 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants